import React from 'react';
import './index.less';
import {connect} from "dva";
import Curd from "components/Curd";
import createColumns from './columns';
import SearchColumns from './searchColumns'
import BaseComponent from "components/Base/BaseComponent";
import SearchBar from "components/Base/SearchBar/SearchBar";


@connect(({patientList}) => ({patientList}))
export default class extends BaseComponent {

  static defaultProps = {
    showAddDelete: false,
    showNum: false,
    bordered: false,
    selectType: 'radio',
    showToolbar: false,
  }

  getNamespace() {
    return 'patientList';
  }

  getTableColumns() {
    return createColumns(this);
  }

  getSearchColumns() {
    return SearchColumns(this);
  }

  render() {

    const dataTableProps = {
      ...this.props,
      showAddDelete: false,
      showNum: true,
      bordered: false,
      selectType: 'radio',
      showToolbar: false,
      namespace: "patientList",
      searchColumns: this.getSearchColumns,
      tableColumns: this.getTableColumns,
      // selectedRowKeys: rows.map(v => v.id),
      // onSelect: (keys, rows) => {
      //   this.setState({rows});
      //   console.log(keys, rows);
      // },
    }

    return (
      <div className={"patient_list"}>
        <SearchBar
          appendTo
          columns={this.getSearchColumns()}
          type="grid"
          cols={{span: 12}}
        />

        <Curd {...dataTableProps}/>
      </div>
    );
  }

}
